﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if IE 6 ]><html class="ie6"><![endif]-->
<!--[if IE 7 ]><html class="ie7"><![endif]-->
<html>
<head>
<title>修改收货信息窗口</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />


<script type="text/javascript" src="../../scripts/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../../scripts/lhgdialog/lhgdialog.js?skin=idialog_1"></script>
<script type="text/javascript" src="../../scripts/jquery/PCASClass.js"></script>
<script type="text/javascript" src="../../admin/js/layout.js"></script>
<link href="../../admin/skin/default/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

  var api = frameElement.api, W = api.opener;
    api.button({
        name: 'confirm',
        focus: true,
        callback: function () {
            submitForm();
            return false;
        }
    }, {
        name: 'cancel',
        callback: function () {
            location.reload(true);
        }
    });
 //页面加载完成执行
    $(function () {
        new PCAS("txtProvince", "txtCity", "txtArea", "北京市");
      
  
      
  });
</script>
  


</head>

<body><div  style="display:none;">
<div id="container"></div>
</div>
<div class="div-content1">
    <dl>
      <dt>name</dt>
      <dd><input type="text" id="txtAcceptName" class="input txt" /> <span class="Validform_checktip">*</span></dd>
    </dl>
    <dl>
      <dt>area</dt>
      <dd>
        <select id="txtProvince"  disabled="disabled" name="txtProvince" class="select"></select>
        <select id="txtCity" name="txtCity" class="select"></select>
        <select id="txtArea" name="txtArea" class="select"></select>
      </dd>
    </dl>
    <dl>
      <dt>address</dt>
      <dd><input type="text" id="txtAddress" class="input normal1"  onblur="ptOutPolygon1()"/> <span class="Validform_checktip">*</span><a href="javascript:void(0)"  onclick="ptOutPolygon();">验证地址</a></dd>
    </dl>
    <dl>
      <dt> zip code</dt>
      <dd><input type="text" id="txtPostCode" class="input txt" /></dd>
    </dl>
    <dl  >
      <dt>Mobile</dt>
      <dd><input type="text" id="txtMobile" class="input txt" /> <span class="Validform_checktip">*</span></dd>
    </dl>
    <dl style="display:none">
      <dt>联系电话</dt>
      <dd><input type="text" id="txtTelphone" class="input txt" /></dd>
    </dl>
      <dl>
      <dt>Default Address</dt>
      <dd  >
          <input id="status" name="status" type="radio" checked=checked value="1" />Yex<input id="status1" type="radio" name="status" value="0" />No</dd>
    </dl>
</div>
   <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=OYonZmtvxwM2fzf71C3rrZvB&services=&t='+(new Date()).getTime()"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/GeoUtils/1.2/src/GeoUtils_min.js"></script>
<script type="text/javascript">
    //窗口API
    var myGeo = new BMap.Geocoder();

    pts = [new BMap.Point(116.230249, 39.995418),
new BMap.Point(116.215302, 39.881233),
new BMap.Point(116.232549, 39.848448),
new BMap.Point(116.269344, 39.815646),
new BMap.Point(116.284292, 39.781054),
new BMap.Point(116.311887, 39.783716),
new BMap.Point(116.377428, 39.77928),
new BMap.Point(116.399275, 39.76242),
new BMap.Point(116.438369, 39.789038),
new BMap.Point(116.488961, 39.812099),
new BMap.Point(116.525756, 39.832492),
new BMap.Point(116.555652, 39.853765),
new BMap.Point(116.547603, 39.943218),
new BMap.Point(116.487812, 40.017524),
new BMap.Point(116.440669, 40.024597),
new BMap.Point(116.341783, 40.025481),
new BMap.Point(116.283142, 40.013988),
new BMap.Point(116.2291, 39.997186)];
    var ply = new BMap.Polygon(pts);
    var fild = 0;
  
   

    //提交表单处理
    function submitForm() {
        //验证表单
      
        if ($("#txtAcceptName").val() == "") {
            W.$.dialog.alert('Please fill in the consignee name！', function () { $("#txtAcceptName").focus(); }, api);
            return false;
        }
        if ($("#txtArea").val() == "") {
            W.$.dialog.alert('Please select a region！', function () { $("#txtProvince").focus(); }, api);
            return false;
        }
        if ($("#txtAddress").val() == "") {

           


            
            W.$.dialog.alert('Please fill in the details of the shipping address！', function () { $("#txtAddress").focus(); }, api);
            return false;
        }
         if ($("#txtPostCode").val() == "") {





            W.$.dialog.alert('Please fill in the zip code！', function () { $("#txtAddress").focus(); }, api);
            return false;
        }
        if (fild != 0) {
            W.$.dialog.alert('Distribution within the rings order only！', function () { $("#txtAddress").focus(); }, api);
            return false;
        }
        if ($("#txtMobile").val() == "" && $("#txtTelphone").val() == "") {
            W.$.dialog.alert('Please fill out the contact phone！', function () { $("#txtMobile").focus(); }, api);
            return false;
        }
        //下一步，AJAX提交表单
        var postData = {
            "order_no": $("#spanOrderNo", W.document).text(), "edit_type": "edit_accept_info",
            "accept_name": $("#txtAcceptName").val(), "province": $("#txtProvince").val(),
            "city": $("#txtCity").val(), "area": $("#txtArea").val(), "address": $("#txtAddress").val(),
            "post_code": $("#txtPostCode").val(), "mobile": $("#txtMobile").val(), "telphone": $("#txtTelphone").val(), status: $('input:radio[name="status"]:checked').val(),"field1":fild
        };
        //发送AJAX请求
        W.sendAjaxUrl(api, postData, "../../tools/submit_ajax.ashx?action=accept_address_add");
        return false;
    }
    


    

  
    
    //;
    
    


</script>

<script type="text/javascript">



    function ptOutPolygon1() {

        var keyword = $("#txtAddress").val();
        if (keyword == "") {
            return;
        }
        myGeo.getPoint(keyword, function (poi) {
            if (poi) {

                var result = BMapLib.GeoUtils.isPointInPolygon(poi, ply);
                if (result == false) {
                    
                     fild = 50;
                }
                else {
                    fild = 0;
                }


            }
            else {
                fild = 0;
            }
            return poi;
        }, "北京");

    }
   

    function ptOutPolygon() {

        var keyword = $("#txtAddress").val();
        if (keyword == "") {
            return;
        }
        myGeo.getPoint(keyword, function (poi) {
            if (poi) {

                var result = BMapLib.GeoUtils.isPointInPolygon(poi, ply);
                if (result == false) {
                   W.$.dialog.tips("Your address outside the rings, only order distribution within the rings！", 4, "32X32/succ.png");
                  //  W.$.dialog.alert('', function () { $("#txtAddress").focus(); }, api);
                    return false;
                    // fild = 0;
                }
                else {
                    W.$.dialog.tips("Your address is within the rings", 4, "32X32/succ.png");
                   // W.$.dialog.alert('您的地址是五环内', function () { $("#txtAddress").focus(); }, api);
                    return false;
                }


            }
            else {
                W.$.dialog.alert('Please input the correct address！', function () { $("#txtAddress").focus(); }, api);
                return false;
            }
            return poi;
        }, "北京");
        
    }
</script>

</body>


</html>